<?php $user=$session->read('User');?>
<?php foreach($competences as $competence)?>
<?php echo $form -> create('projects', array('url' => '/projects/editfile/edit','enctype'=>'multipart/form-data','type'=> 'post','onsubmit'=>'return checksave()') ); ?>
<div class="right_side_operate_area">
	<div class="right_side_title left"><h2><?php echo $html->link($pname,"/projects/showinfo/".$pid); ?></h2></div>
    <div class="right back_btn"><?php echo $html->link("返回","/projects/showinfo/".$pid);?></div>
    <div class="clear"></div>
</div>
<div class="right_side_scollbar">
    <div class="detail_info_panel">
     <?php 
		  $ised=$action->checkPermissions($user,"edit",$first_ownerid);
	 if($ised){?>
	  <b><font color='green'><?php echo "请选择需要公开材料:";?></font></b>
    	<div class="details_info_content">
    	<font size='2px'>
    		<?php
    			foreach($pfiletype as $key=>$filetype)
    			{
    				$c="";
    				if(!empty($competences)){
	    				foreach($competences as $competence){
	    				if($competence["visible"]==$key){
			    				$c="checked";
    					}
    				}
				}
			 	echo "<label><input id='profile' type='checkbox' name='file' $c value='$key'/>$filetype</label>&nbsp&nbsp&nbsp&nbsp";
		 		}?></font>
		 	<?php  echo $form->hidden('Competence.file'); ?>
		 	<?php  echo $form->hidden('Competence.value'); ?>
			<?php  echo $form->hidden('Competence.id'); ?>
		 	<?php echo $form->submit('确定', array("div"=>false,"onclick"=>"checkfile()")) ?>
		 	<hr/>
	    <?php }?>
				<?php 
				$dan="'";
				$ised=$action->checkPermissions($user,"edit",$first_ownerid);
				foreach($pfiletype as $key=>$filetype){
					foreach($competences as $competence){
						$dis="none";
						if($competence["visible"]==$key){
							$dis="block";
							break;
						}
					}
					if($ised){
						$dis="block";
					}
					?>
		        <div class="category_file_block" style="display:<?php echo $dis?>">
		        	<div class="category_title"><?php echo $filetype ?></div>
		        	<div class="file_list_panel">
		        		 <?php 
		        		 	$fildisplay="暂无文件";
	        		 		if(!empty($attachments)){
								foreach($attachments as $attachment) {
									if($key==$attachment["cvid"]){
										$fildisplay="";
									}
								}
							}
						 ?>
		        		 <div class="file_category_list">
		        			<div class="file_lists" diaplay="none" id="filelist<?php echo $key?>">
		        				<ul class="file_attach">
		        					<?php 
	        						echo $fildisplay;
									if(!empty($attachments)){
										foreach($attachments as $attachment){
											if($key==$attachment["cvid"]){
												echo "<li>";
												echo "<span>".$html->link($attachment["file_name"],'/projects/download/'.$attachment["id"],null)."</span>";
												echo "<span class='source_upload_date'>".date("Y-m-d",strtotime($attachment["created"]))."</span>";
												$ised=$action->checkPermissions($user,"edit",$first_ownerid);
												if($ised){echo '<span class="source_upload_delete"><a title="删除" onclick="delfile(this,'.$dan.$attachment["id"].$dan.','.$dan.$key.$dan.')" href="javascript:void(0)"></a></span>';}
												echo "</li>";
											}
										}
									}
								?>
							</ul>
						</div>
					 </div>
		        		 <?php 
		        		  $ised=$action->checkPermissions($user,"edit",$first_ownerid);
		        		 if($ised){?>
		        		 <div class="file_attache_area">
                        	<a id="add_float_box_btn<?php echo $key?>" href="javascript:void(0)">添加文件</a>
                            <div class="file_upload_box" id="add_float_box<?php echo $key?>" style="display:none;">
                            	<div class="file_upload_choose_panel">
                                	<div class="file_upload_box_head">
                                    	<div class="left float_box_title">选择上传文件</div>
                                        <div class="right float_box_close close<?php echo $key?>"><a href="javascript:void(0)"></a></div>
                                        <div class="clear"></div>
                                    </div>
                                    <div class="file_choose_area">
                                    	<div id="add1<?php echo $key?>" class="left text_box"> 
											<div class="file_add_box">
												<input type="file" id="upload[]" name="upload<?php echo $key?>[]" />
											</div>
										</div>
						        		<div class="clear"></div>
										<div id="add2<?php echo $key?>" class="left filelist"></div>
										<div class="left clear">
											<div class="left add_sub_file_btn">
												<span onclick="addmore('<?php echo $key?>')" href="#"><?php echo $html->image('list-add.png')?></span>&nbsp;
												<span onclick="removemore('<?php echo $key?>')" href="#"><?php echo $html->image('list-remove.png')?></span>
											</div>
										</div>
										<div class="details_item_line edit_form_btn clear">
			    							<div class="details_item">
												<div class="form_add_submit left">
										            <?php echo $form->submit(__('Save',true), array("div"=>false)) ?>
										            <?php  echo $form->hidden('Project.id'); ?>
										        </div>
									        </div>
								        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
		        		<script type="text/javascript">
                        	$(document).ready(function() {
                                $("#add_float_box_btn<?php echo $key?>").click(function() {
									$("#add_float_box<?php echo $key?>").slideDown("fast");
                                });
								$(".close<?php echo $key?>").click(function() {
									$("#add_float_box<?php echo $key?>").slideUp("fast");
								});
                            });
                        </script>
                        <?php }?>
			        </div>
			    </div>
		    <?php }?>
		</div>
	</div>
</div>
</form>
<?php  echo $form->hidden('Project.id'); ?>
<?php echo $this->element('delfileconfirm',array("title"=>"删除提示","message"=>"你确定要删除吗？")) ?>
<script>
$(document).ready(function() {
	$.extend({
		getDetailInfoH:function() {
			if($("#add_float_box<?php echo $key?>").attr("style") != "display: none;") {
				var detailInfoH = $(".details_info_content").height() + $("#add_float_box<?php echo $key?>").height() - 60;
				$(".detail_info_panel").css("height",detailInfoH+"px");
			} else {
				$(".detail_info_panel").css("height",$(".details_info_content").height()+"px");
			}
		}
	});
	setInterval("$.getDetailInfoH()",1000);
});
//$("input[name='file']").click(checkfile);
function checkfile()
{
  var z=''; 
  $('input[name="file"]:checked').each(function(){ 
    z+=$(this).val()+','; 
  });
  $("#CompetenceFile").val(z);
    $("#CompetenceValue").val("1");
  //alert(z);
}
</script>